/*
Package routers
register and include routers.
*/

package routers

import (
	"gitee.com/RocsSun/webhook/pkg/serve/service"
	"github.com/gin-gonic/gin"
)

type Option func(*gin.Engine)

var options []Option

// Include load router.
func Include(opts ...Option) {
	options = append(options, opts...)
}

// Register router to gin.Engine.
func Register(r *gin.Engine) {
	for _, opt := range options {
		opt(r)
	}
}

// SetDefaultRouter 配置路由。
func SetDefaultRouter() *gin.Engine {
	r := gin.Default()
	Include(service.Router)
	Register(r)
	return r
}
